from application.entity import BaseOutEntity
from application.enumeration.NoteTypeEnum import NoteTypeEnum
from pydantic import BaseModel, Field, StrictInt, AnyHttpUrl
from typing import Optional


class NoteBase(BaseModel):
    """
    帖子基本实体
    """
    title: str = Field(max_length=20, min_length=2)
    content: str = Field(max_length=1000, min_length=10)


class NoteAdd(NoteBase):
    """
    帖子新增实体
    """
    video: Optional[str]  # 视频URL
    image_list: list[Optional[str]] = []  # 图片URL列表
    note_type: NoteTypeEnum = NoteTypeEnum.ORIGINAL


class NoteEdit(NoteAdd):
    """
    帖子修改实体
    """
    id: StrictInt


class NoteOut(BaseOutEntity, NoteBase):
    """
    帖子输出实体
    """
    user_id: StrictInt
    video: AnyHttpUrl = None  # 视频URL
    image_list: list[Optional[AnyHttpUrl]] = []  # 图片URL列表
    note_type: NoteTypeEnum = NoteTypeEnum.ORIGINAL
    like_num: StrictInt = 0  # 点赞数
    forward_num: StrictInt = 0  # 转发数
    comment_num: StrictInt = 0  # 评论数
    share_num: StrictInt = 0  # 分享数
    view_num: StrictInt = 0  # 浏览数
    is_disabled: bool = False
